# encoding: utf-8
import os
from copy import deepcopy

############################       项目gitee远程仓库地址       https://gitee.com/datacenter-han/autoflow.git

base_path = os.path.dirname(__file__).replace("\\", "/")

# start_url = "https://tyrz.chinatorch.org.cn/hjismp/a/login#gq"
start_url = "https://fuwu.most.gov.cn/"
validate_code_path = base_path + "/images/validate_code/"

# chrome_driver_path = base_path + "/driver/chromedriver.exe"
# # #  使用与浏览器版本相差最小的 驱动。
chrome_driver_path = base_path + "/driver/90/chromedriver.exe"

# # # 材料路径
materials_path = base_path.replace("/", "\\") + "\\" + "materials"

log_path = base_path + "/log/log.txt"

cut_screen_process_img = "../images/00_screen_image.png"

is_test = True
# # # 云打码平台账号信息
ydm_appid = 9538
ydm_appkey = b"129321897e1a110e3c449a37d4e3843d"
ydm_username = b"2812382024"
ydm_password = b"547643835."

# redis 配置信息
redis_host = "192.168.1.50"
redis_port = 8779
redis_db = 1
redis_password = "qazwsx123"

# 超级鹰打码平台账号信息
# username = '17505251998'
# password = 'yinbohang1'
# soft_id = '905824'
username = "wyt123456"
password = "547643835."
soft_id = "905919"

# 阿里云 oss对象存储信息
oss_id = "LTAI4G9dLAHHnSuQzwje6vpH"
oss_secret = "6nXrhDV2JCeG5eszPKFdNZJOOCkbNt"
oss_endpoint = "http://oss-cn-beijing.aliyuncs.com"

# 阿里云短信配置
sms_id = "LTAIIov68y5XLPal"
sms_secret = "ZKmJAp0AVDmSJinX7L5TSsBYps091D"

db_config = {
    "host": "192.168.1.4",
    "port": 3306,
    "user": "root",
    "password": "Busiuess@2018",
    "charset": "utf8",
}
dev_config = {
    "host": "192.168.1.50",
    "port": 3306,
    "user": "root",
    "password": "hzdata@2020",
    "charset": "utf8",
}
# dev_config = {
#     "host": "127.0.0.1",
#     "port": 3306,
#     "user": "root",
#     "password": "123456",
#     "charset": "utf8"
# }
localhost_config = {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "",
    "charset": "utf8"
}
online_config = {
    "host": "rm-2zee98ev4810q9w952o.mysql.rds.aliyuncs.com",
    "port": 3306,
    "user": "datacenter_han",
    "password": "X38bNk5a!zj3#zuBQEWV",
    "charset": "utf8"
}

# 对比哪一年的材料信息，若为空字符串，则默认对比当年材料信息
check_year = ""

# 材料状态
material_status = {
    "completed": "已报备",
    "underway": "申报材料填写中",
}

# # # # # # # # #  web_type=1 是国网， web_type=2 是省网
# web_type = 1
web_type = "ctp"
site_type = "GR"

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # TODO 填写多选框右侧的 textarea 文本框时， 可以 和选项对比一下。

# # # # #      需要逐条添加数据的表单：

#              注册登记表中的股权结构表
#              知识产权汇总表
#              企业开发活动情况表
#              企业年度研究开发费用结构明细表
#              上年度高新技术产品（服务）情况表
#              科技成果转化情况表

MultiRecordList = [
    "WriteIPForm", "WriteRDForm", "WriteRdcostForm", "WritePSForm", "IAStaDesc", "WriteStandForm"
]

# TODO 包含省网的行政区划代码
IncludeProvinceSiteArea = [320000]
# "WriteCivilType", "WriteLegalType", "WriteVentureInvestment",

# # # # # # # # # # # # # # # # TODO 上传文件编写方法待定
# # # # #      含有附件上传按钮的表单：
#              知识产权汇总表
#              人力资源情况表
#              企业研究开发活动情况表
#              上年度高新技术产品（服务）情况表
#              科技成果转化情况表
#              研究开发与技术创新管理组织情况
#              企业参与国家标准或行业标准制定情况汇总表
#              上传附件

res_base_sql = "select file_path from {table}"

ResTypeMapping = {
    "WriteIPForm": "ip",
    "WriteRDForm": "rd",
    "WritePSForm": "ps",
    "IAStaDesc": "sta",
    "WriteStandForm": "std",
    "WriteHRForm": "hr",
    # 研究开发与技术创新管理组织情况
    "IARdmDesc": {u"研发费用辅助账": "rdeaa", u"产学研合作证明": "cooperation", u"创新创业平台": "iep", u"评价奖励制度": "ers"},
    # 上传附件
    # , u"申请书封皮": "appcvr"
    "UploadAccessory": {u"营业执照": "buslic", u"财务审计报告": "farpt", u"高新产品": "psrpt",
                        u"企业所得税纳税申报表": "raxrtn", u"近三年研发费用专项审计报告": "rdcostrptr", u"认定机构要求上传的其他附件": "otheratt"},
}
TypeSqlMapping = {
    "ip": {"table": "ent_res_ipr",
           "condition": "where co_id={co_id} and year={year} and ipr_id={id}"},
    "rd": {"table": "ent_res_rd",
           "condition": "where co_id={co_id} and year={year} and rd_id={id}"},
    "ps": {"table": "ent_res_ps",
           "condition": "where co_id={co_id} and year={year} and ps_id={id}"},
    "sta": {"table": "ent_res_sta",
            "condition": "where co_id={co_id} and year={year} and (id)={id}"},
    "std": {"table": "ent_res_stand",
            "condition": "where co_id={co_id} and year={year} and (id)={id}"},
}



rule_json = \
    {"type": "ctp",
     "content": [{"id": 1, "type": "buslic", "name": "营业执照", "required": "yes", "mode": "single", "size": "0.5"},
                 {"id": 3, "type": "farpt", "name": "近三年财务审计报告", "required": "no", "mode": "multiple", "children": [
                     {"id": 4, "type": "farpt", "name": "财务审计报告", "required": "yes", "mode": "single", "calculate": -3,
                      "size": "4"},
                     {"id": 5, "type": "farpt", "name": "财务审计报告", "required": "yes", "mode": "single", "calculate": -2,
                      "size": "4"},
                     {"id": 6, "type": "farpt", "name": "财务审计报告", "required": "yes", "mode": "single", "calculate": -1,
                      "size": "4"}]},
                 {"id": 7, "type": "psrpt", "name": "近一年高新产品（服务）收入专项审计报告", "required": "yes", "mode": "single",
                  "size": "2"},
                 {"id": 8, "type": "raxrtn", "name": "近三年企业所得税纳税申报表", "required": "no", "mode": "multiple",
                  "children": [{"id": 9, "type": "raxrtn", "name": "企业所得税纳税申报表", "required": "yes", "mode": "single",
                                "calculate": -3, "size": "2"},
                               {"id": 10, "type": "raxrtn", "name": "企业所得税纳税申报表", "required": "yes", "mode": "single",
                                "calculate": -2, "size": "2"},
                               {"id": 11, "type": "raxrtn", "name": "企业所得税纳税申报表", "required": "yes", "mode": "single",
                                "calculate": -1, "size": "2"}]},
                 {"id": 12, "type": "rdcostrptr", "name": "近三年研发费用专项审计报告", "required": "yes", "mode": "single",
                  "size": "2"},
                 {"id": 13, "type": "otheratt", "name": "认定机构要求上传的其他附件", "required": "yes", "mode": "single",
                  "size": "2"},
                 {"id": 14, "type": "ip", "name": "知识产权", "required": "no", "mode": "one-to-one", "size": "2",
                  "fields": [{"field": "id", "name": "", "visible": "false", "field_db": "id"},
                             {"field": "ipr_id", "name": "知识产权编号", "visible": "false", "field_db": "ipr_id"},
                             {"field": "file_path", "name": "文件路径", "visible": "false", "field_db": "file_path"},
                             {"field": "file_start", "name": "页码", "visible": "true", "field_db": "file_start"},
                             {"field": "file_end", "name": "区间", "visible": "true", "field_db": "file_end"},
                             {"field": "iprIdName", "name": "知识产权编号", "visible": "true", "field_db": ""},
                             {"field": "ipr_name", "name": "知识产权名称", "visible": "true", "field_db": "ipr_name"}]},
                 {"id": 15, "type": "hr", "name": "人力资源", "required": "yes", "mode": "single", "size": "4"},
                 {"id": 16, "type": "rd", "name": "企业研究开发活动", "required": "no", "mode": "one-to-one", "size": "2",
                  "fields": [{"field": "id", "name": "", "visible": "false", "field_db": "id"},
                             {"field": "rd_id", "name": "研发活动编号", "visible": "false", "field_db": "rd_id"},
                             {"field": "file_start", "name": "页码", "visible": "true", "field_db": "file_start"},
                             {"field": "file_end", "name": "区间", "visible": "true", "field_db": "file_end"},
                             {"field": "rdIdName", "name": "研发活动编号", "visible": "true", "field_db": ""},
                             {"field": "rd_name", "name": "研发活动名称", "visible": "true", "field_db": "rd_name"},
                             {"field": "file_path", "name": "文件路径", "visible": "false", "field_db": "file_path"}]},
                 {"id": 17, "type": "ps", "name": "企业高新技术产品（服务）", "required": "no", "mode": "one-to-one", "size": "2",
                  "fields": [{"field": "id", "name": "", "visible": "false", "field_db": "id"},
                             {"field": "ps_id", "name": "产品编号", "visible": "false", "field_db": "ps_id"},
                             {"field": "file_start", "name": "页码", "visible": "true", "field_db": "file_start"},
                             {"field": "file_end", "name": "区间", "visible": "true", "field_db": "file_end"},
                             {"field": "psIdName", "name": "产品编号", "visible": "true", "field_db": "ps_id"},
                             {"field": "ps_name", "name": "产品（服务）名称", "visible": "true", "field_db": "ps_name"},
                             {"field": "file_path", "name": "文件路径", "visible": "false", "field_db": "file_path"}]},
                 {"id": 18, "type": "sta", "name": "科技成果转化", "required": "no", "mode": "one-to-one", "size": "2",
                  "fields": [{"field": "id", "name": "", "visible": "false", "field_db": "id"},
                             {"field": "file_start", "name": "页码", "visible": "true", "field_db": "file_start"},
                             {"field": "file_end", "name": "区间", "visible": "true", "field_db": "file_end"},
                             {"field": "sta_name", "name": "科技成果名称", "visible": "true", "field_db": "sta_name"},
                             {"field": "file_path", "name": "文件路径", "visible": "false", "field_db": "file_path"}]},
                 {"id": 19, "type": "std", "name": "企业参与国家标准或行业标准制定", "required": "no", "mode": "one-to-one",
                  "size": "2", "fields": [{"field": "id", "name": "", "visible": "false", "field_db": "id"},
                                          {"field": "file_start", "name": "页码", "visible": "true",
                                           "field_db": "file_start"},
                                          {"field": "file_end", "name": "区间", "visible": "true",
                                           "field_db": "file_end"},
                                          {"field": "stand_num", "name": "标准编号", "visible": "true",
                                           "field_db": "stand_num"},
                                          {"field": "stand_name", "name": "标准名称", "visible": "true",
                                           "field_db": "stand_name"},
                                          {"field": "file_path", "name": "文件路径", "visible": "false",
                                           "field_db": "file_path"}]},
                 {"id": 20, "type": "rdeaa", "name": "制定了企业研究开发的组织管理制度，建立了研发投入核算体系，编制了研发费用辅助账证明材料", "required": "yes",
                  "mode": "single", "size": "2"},
                 {"id": 21, "type": "cooperation", "name": "设立内部科学技术研究开发机构并具备相应科研条件，与国内外研究开发机构开展多种形式的产学研合作证明材料",
                  "required": "yes", "mode": "single", "size": "2"},
                 {"id": 22, "type": "iep", "name": "建立了科技成果转化的组织实施与激励奖励制度，建立开放式的创新创业平台证明材料", "required": "yes",
                  "mode": "single", "size": "2"},
                 {"id": 23, "type": "ers", "name": "建立了科技人员的培养进修、职工技能培训、优秀人才引进，以及人才绩效评价奖励制度证明材料", "required": "yes",
                  "mode": "single", "size": "2"}]}

# # # # # # #  每个class中所需的数据对应在哪个数据库，哪张表，都需要什么字段。
# #  查询条件，基本条件 ----- co_id 需要和登录信息相等
# # 以下查询均有条件  co_id=xxx
# # 添加字典值，从数据库取出数据时，将 value 与对应的 label 替换

replace_map = {"；": ";", "，": ",", "、": ",", "（": "(", "）": ")", "‘": "", "“": "", "”": "", "’": "", "【": "[", "】": "]",
               "。": ".", " ": "", "\t": "", "\n": "", "\xa0": ""}

CLASSDATADICT = {
    # 申请书封皮
    "WriteApplicationCover": {
        "database": "hitech",
        "table": "ent_yearstatus",
        "fields": ("cert_org", "app_date"),
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # 注册登记表
    "WriteRegistrationForm": {
        "database": "hitech",
        "table": "ent_info",
        # # # # # 注册资金 ？= 企业规模  SCALE-规模枚举值   -------
        # # # # # 通信地址 由 省 市 区 所在乡镇 所在街道   具体地址xx号xx楼xx层xxx没有找到           ---------------  省市区 需要通过邮政编码调用高德api获取。
        # # # # # DOM 住所 对应通信地址  ----------- TODO  HITECH_FIELD_NAMELIST 该字段需要进行处理，按照 , 拆分为三个值。
        # # # GOPUBLIC 是否上市 0未上市 1已上市------- STOCKCAT 为字典值，是上市类型 -------- GOPUBLICTIME 上市时间 ------ STOCKCODE 股票代码 ------
        # # # OPSCOPE 经营范围 --------- ENTBRIEF_INTRO 企业简介

        # # 小于2000万元（含） --- 小于2000万元（含）
        # # 2000万元以上 ~ 5000万元（含） --- 2000万元以上~5000万元（含）
        # # 5000万元以上 ~ 1亿元（含） --- 5000万元以上~1亿元（含）
        # # 1亿元以上 ~ 2亿元（含） --- 1亿元以上~2亿元（含）
        # # 2亿元以上 ~ 4亿元（含） --- 2亿元以上~4亿元（含）
        # # 4亿元以上 --- 4亿元以上
        # CONTACT,CONTACT_PHONE,CONTACT_TEL,CONTACT_FAX,CONTACT_EMAIL,LEGAL_PHONE,LEGAL_TEL,LEGAL_FAX,LEGAL_EMAIL,DOM,POSTALCODE,SCALE,HITECH_FIELD_NAMELIST,GOPUBLIC,STOCKCAT,GOPUBLICTIME,STOCKCODE,OPSCOPE,ENTBRIEF_INTRO
        # contact,contact_phone,contact_tel,contact_fax,contact_email,legal_phone,legal_tel,legal_fax,legal_email,dom,postalcode,scale,hitech_field_namelist,gopublic,stockcat,gopublictime,stockcode,opscope,entbrief_intro

        "fields": (
            "esdate", "contact", "contact_phone", "contact_tel", "contact_fax", "contact_email", "legal_phone",
            "legal_tel",
            "legal_fax", "legal_email",
            "dom", "postalcode", "scale", "hitech_field_namelist", "hitech_field_idlist", "gopublic", "stockcat",
            "gopublictime", "stockcode",
            "opscope", "entbrief_intro"),
        "dict_value": {"scale": "ent_scale", "stockcat": "HAN08"},
        "condition": {"where": [f"co_id=g.co_id", "and", "year=g.year"]}
    },
    # 股权结构 --------------- 公民类型
    "WriteCivilType": {
        "database": "hitech",
        "table": "ent_equity_citizen",
        # # # type 为字典值
        "fields": ("type", "name", "id_num", "invest"),
        "dict_value": {"type": "citizen_type", },
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # 股权结构 --------------- 法人类型
    "WriteLegalType": {
        "database": "hitech",
        "table": "ent_equity_legal",
        # # # type 为字典值
        "fields": ("type", "name", "code", "invest"),
        "dict_value": {"type": "legal_type", },
        # # # 需要有条件 is_risk 判断，将是风险投资的法人剔除
        "condition": {"where": [f"co_id=g.co_id", "and", "is_risk=0", "and", f"year=g.year"]}
    },
    # 股权结构 --------------- 风险投资
    "WriteVentureInvestment": {
        "database": "hitech",
        "table": "ent_equity_legal",
        # # # type 为字典值
        "fields": ("type", "name", "code", "invest"),
        "dict_value": {"type": "legal_type", },
        # # # 需要有条件 is_risk 判断，将不是风险投资的法人剔除
        "condition": {"where": [f"co_id=g.co_id", "and", "is_risk=1", "and", f"year=g.year"]}
    },
    # 知识产权汇总表
    "WriteIPForm": {
        "database": "hitech",
        "table": "ent_res_ipr",
        # ipr_num="1", ipr_type="外观设计专利", patent_num="CN201410781695.1", ipr_name="一种吊顶的挂接系统", ipr_getway="自主研发", auto_date="2019-12-12"
        "fields": ("ipr_id", "ipr_type", "auth_num", "ipr_name", "ipr_getway", "auth_date", "oss_path"),
        "dict_value": {"ipr_type": "ipr_type", "ipr_getway": "ipr_getway"},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # 人力资源情况表 ------------- 总体情况
    "WriteHRInfo": {
        "database": "hitech",
        "table": "ent_res_hrinfo",
        "fields": ("type", "total", "onjob", "parttime", "tempstaff", "foreigner", "returnees", "thstalents"),
        # type 为 字典值， 但在 sys_dict 中找不到，所以直接在程序中判断，进行填写。
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # 人力资源情况表 ------------ 全体人员结构
    # "WriteHRSubinfo": {
    "WriteHRForm": {
        "database": "hitech",
        "table": "ent_res_hrsubinfo",
        "fields": (
            "doctor", "md", "bd", "coll", "senior", "medium", "primary", "snengr", "age30al", "age40al", "age50al",
            "age51au"),
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # 企业研究开发活动情况表
    "WriteRDForm": {
        "database": "hitech",
        "table": "ent_res_rd",
        "fields": (
            "rd_id", "rd_name", "start_date", "end_date", "tech_fieldname", "tech_fieldlist", "tech_source", "ipr_ids",
            "ipn_ids", "rd_budget",
            "rd_spend1styear", "rd_spend2ndyear", "rd_spend3rdyear", "ooim", "cti", "pra", "oss_path"),
        "dict_value": {"tech_source": "tech_source", },
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # 企业年度研究开发费用结构明细表
    "WriteRdcostForm": {
        "database": "hitech",
        "table": "ent_res_rdcost",
        "fields": (
            "rd_id", "peryear", "int_amount", "int_labor", "int_direct_inv", "int_de_lta", "int_aia", "int_design",
            "int_ecct", "int_other", "ext_amount", "ext_inchina", "amount", "reporter", "sig_date", "sort_num"),
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # 上年度高新技术产品（服务）情况表
    "WritePSForm": {
        "database": "hitech",
        "table": "ent_res_ps",
        "fields": (
            "ps_id", "ps_name", "tech_fieldname", "tech_fieldlist", "tech_source", "sales_revenue", "is_major",
            "ipr_ids", "ipn_ids", "keytech_ind",
            "caosp", "aipr_tsp", "oss_path"),
        "dict_value": {"tech_source": "tech_source"},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # 主要情况表
    "WriteMaincaseForm": {
        "database": "hitech",
        "table": "ent_res_maincase",
        "fields": ("tech_fieldname", "tech_fieldlist", "inchina_spend", "basic_spend", "mat_ai", "is_events"),
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # 主要情况表 ---------------- 经营情况
    "WriteOptcond": {
        "database": "hitech",
        "table": "ent_res_optcond",
        "fields": ("category", "net_assets", "net_revenues", "net_income"),
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # # 企业创新能力
    "WriteInnovationAbilityForm": {
        "database": "hitech",
        "table": "ent_res_innoinfo",
        "fields": ("ripr_iec", "sta_desc", "rdm_desc", "mgt_tech"),
        "dict_value": {},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # # 企业创新能力 --------- 科技成果转化情况
    "IAStaDesc": {
        "database": "hitech",
        "table": "ent_res_sta",
        "fields": (
            "id", "sta_name", "sta_type", "sta_source", "trans_result", "trans_date", "sort_num", "ipr_ids", "rd_ids",
            "ipn_ids", "ps_ids", "trans_ids", "oss_path"),
        "dict_value": {"sta_type": "cstad_type", "sta_source": "cstad_source", "trans_result": "cstad_result",
                       "trans_ids": "trans_form"},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year"]}
    },
    # # # 企业参与国家标准或行业标准制定情况汇总表
    "WriteStandForm": {
        "database": "hitech",
        "table": "ent_res_stand",
        "fields": ("id", "stand_name", "stand_num", "stand_level", "stand_way", "oss_path"),
        "dict_value": {"stand_level": "standard_level", "stand_way": "prtp_mode"},
        "condition": {"where": [f"co_id=g.co_id", "and", f"year=g.year", "order by id desc"]}
    }
}

check_map = {
    "WriteApplicationCover": "WriteApplicationCover",
    "WriteRegistrationForm": "WriteRegistrationForm",
    "WriteCivilType": "WriteRegistrationForm",
    "WriteLegalType": "WriteRegistrationForm",
    "WriteVentureInvestment": "WriteRegistrationForm",
    "WriteIPForm": "WriteIPForm",
    "WriteHRInfo": "WriteHrForm",
    # "WriteHRSubinfo": "WriteHrForm",
    "WriteHRForm": "WriteHrForm",
    "WriteRDForm": "WriteRDForm",
    "WriteRdcostForm": "WriteRdcostForm",
    "WritePSForm": "WritePSForm",
    "WriteMaincaseForm": "WriteMaincaseForm",
    "WriteOptcond": "WriteMaincaseForm",
    "WriteInnovationAbilityForm": "WriteInnovationAbilityForm",
    "IAStaDesc": "IAStaDesc",
    "WriteStandForm": "WriteStandForm",
}

class_to_tablename = {
    "WriteRegistrationForm": "企业注册登记表",
    "WriteCivilType": "企业注册登记表",
    "WriteLegalType": "企业注册登记表",
    "WriteVentureInvestment": "企业注册登记表",
    "WriteRDForm": "企业研究开发活动情况",
    "WritePSForm": "上年度高新技术产品（服务）情况",
    "WriteMaincaseForm": "主要情况",
    "IAStaDesc": "科技成果转化情况"
}

CLASSMODELMAPPING = {
    "WriteApplicationCover": {"field": "ent_status", "restart_model": "WriteApplicationCover", "rd_id": "1",
                              "rd_name": "申请书封皮"},
    "WriteRegistrationForm": {"field": "entinfo_status", "restart_model": "WriteRegistrationForm", "rd_id": "",
                              "rd_name": "企业注册登记表"},
    "WriteCivilType": {"field": "", "restart_model": "WriteRegistrationForm", "rd_id": "2",
                       "rd_name": "股权结构"},
    "WriteLegalType": {"field": "", "restart_model": "WriteRegistrationForm", "rd_id": "2",
                       "rd_name": "股权结构"},
    "WriteVentureInvestment": {"field": "", "restart_model": "WriteRegistrationForm", "rd_id": "3",
                               "rd_name": "风险投资"},
    "WriteIPForm": {"field": "ip_status", "restart_model": "WriteIPForm", "rd_id": "6", "rd_name": "知识产权",
                    "biz_code": "ipr_id", "biz_name": "ipr_name"},
    "WriteHRForm": {"field": "hr_status", "restart_model": "WriteHRForm", "rd_id": "7", "rd_name": "人力资源情况"},
    "WriteHRInfo": {"field": "", "restart_model": "WriteHRForm", "rd_id": "7", "rd_name": "人力资源情况"},
    # "WriteHRSubinfo": {"field": "hr_status", "restart_model": "WriteHRForm", "rd_id": "7", "rd_name": "人力资源情况"},
    # "WriteHRForm": {"field": "hr_status", "restart_model": "WriteHRForm", "rd_id": "7", "rd_name": "人力资源情况"},
    "WriteRDForm": {"field": "rd_status", "restart_model": "WriteRDForm", "rd_id": "8", "rd_name": "企业研究开发活动情况",
                    "biz_code": "rd_id", "biz_name": "rd_name"},
    "WriteRdcostForm": {"field": "rdcost_status", "restart_model": "WriteRdcostForm", "rd_id": "9",
                        "rd_name": "企业年度研究开发费用结构", "biz_code": "rd_id"},
    "WritePSForm": {"field": "ps_status", "restart_model": "WritePSForm", "rd_id": "10", "rd_name": "上年度高新技术产品（服务）情况",
                    "biz_code": "ps_id", "biz_name": "ps_name"},
    "WriteMaincaseForm": {"field": "maincase_status", "restart_model": "WriteMaincaseForm", "rd_id": "4",
                          "rd_name": "主要情况"},
    "WriteOptcond": {"field": "", "restart_model": "WriteMaincaseForm", "rd_id": "5",
                     "rd_name": "近三年经营情况"},
    "WriteInnovationAbilityForm": {"field": "innoinfo_status", "restart_model": "WriteInnovationAbilityForm",
                                   "rd_id": "11", "rd_name": "企业创新能力"},
    "IAStaDesc": {"field": "sta_status", "restart_model": "WriteInnovationAbilityForm", "rd_id": "12",
                  "rd_name": "科技成果转化情况", "biz_name": "sta_name"},
    "WriteStandForm": {"field": "stand_status", "restart_model": "WriteStandForm", "rd_id": "14",
                       "rd_name": "企业参与国家标准或行业标准制定情况", "biz_name": "stand_name"},
    "UploadAccessory": {"field": "upload_status", "restart_model": "UploadAccessory", "rd_id": "", "rd_name": "其他附件"},
}

FIELDCLASSMAPPING = {v.pop("field"): v for k, v in deepcopy(CLASSMODELMAPPING).items()}

restartModel = [v.get("restart_model") for k, v in deepcopy(CLASSMODELMAPPING).items()]

if __name__ == '__main__':
    # path = materials_path + "\\{}_{}\\{}\\{}_{}"
    # print(path.replace("\\", "/"))
    # print(FIELDCLASSMAPPING)
    #
    # print(CLASSMODELMAPPING)
    from PageObject.UploadAccessory import UploadAccessory
    from PageObject.WriteApplicationCover import WriteApplicationCover
    from PageObject.WriteHrForm import WriteHRForm
    from PageObject.write_innovation_ability_form import WriteInnovationAbilityForm
    from PageObject.WriteIpForm import WriteIPForm
    from PageObject.WriteMaincaseForm import WriteMaincaseForm
    from PageObject.WritePsForm import WritePSForm
    from PageObject.WriteRdForm import WriteRDForm
    from PageObject.WriteRdcostForm import WriteRdcostForm
    from PageObject.WriteRegistrationForm import WriteRegistrationForm
    from PageObject.WriteStandForm import WriteStandForm

    # for i in FIELDCLASSMAPPING:
    #     # print("{} --{}".format(i, FIELDCLASSMAPPING.get(i)))
    #     page = globals()[FIELDCLASSMAPPING.get(i).get("restart_model")](driver="a")
    #     # page.main()
    #     print(page)
    # for k, v in FIELDCLASSMAPPING.items():
    #     if "status_records" in k or "status_records" in v:
    #         # print(f"{{}: {} }")
    #         pass
    # for i in FIELDCLASSMAPPING:
    #     class_name = FIELDCLASSMAPPING.get(i).get("restart_model")
    #     print(class_name)
    print(CLASSDATADICT.keys())
